package com.example.zce.library.common.bean;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述：
 *
 * @author zengyz
 * @date 2018/7/29 7:20
 */
public class ResultMapBean extends HashMap<String, Object> {

    public ResultMapBean() {
        put("code", 200);
    }

    public static ResultMapBean error() {
        return error(500, "未知异常，请联系管理员");
    }

    public static ResultMapBean error(String msg) {
        return error(500, msg);
    }

    public static ResultMapBean error(int code, String msg) {
        ResultMapBean ru = new ResultMapBean();
        ru.put("code", code);
        ru.put("msg", msg);
        return ru;
    }

    public static ResultMapBean ok(String msg) {
        ResultMapBean ru = new ResultMapBean();
        ru.put("msg", msg);
        return ru;
    }

    public static ResultMapBean ok(Map<String, Object> map) {
        ResultMapBean ru = new ResultMapBean();
        ru.putAll(map);
        return ru;
    }

    public static ResultMapBean ok() {
        return new ResultMapBean();
    }

    @Override
    public ResultMapBean put(String key, Object value) {
        super.put(key, value);
        return this;
    }
}
